lib/repo: Skip import via hardlink if repo owners don't match
authorColin Walters <walters@verbum.org>
Mon, 12 Jun 2017 17:20:42 +0000 (13:20 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Tue, 13 Jun 2017 12:02:12 +0000 (12:02 +0000)
commit695771667c7736f3c69b74a6a3f344b36aff1e41
treec77208308d241f6b21462d489770c31aa4146214
parent21eec96bfdc553fc77f842776758c3dfe61e0185
lib/repo: Skip import via hardlink if repo owners don't match

Before this, if one had repos of matching mode but different owners,
which could happen if one e.g. makes a `bare` non-root repo in
`/ostree/deploy/$stateroot/var/tmp`, every time we tried to call `linkat()`
we'd get `EPERM` and fall back to a copy.

Fix this by saving the repo owner uid, and avoid trying to call `linkat()` if we
know it's going to fail. Of course most commonly in this scenario we'll
immediately fail trying to `chown` the files to `0`, but this is prep for a
future patch to improve `bare-user` → `bare-user-only` imports where we'll be a
bit more sophisticated.

Closes: #922
Approved by: alexlarsson
src/libostree/ostree-repo-private.h
src/libostree/ostree-repo.c